import os
from celery import Celery

from celery.schedules import crontab

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'spinct.settings')

app = Celery('spinct')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

# 使用 Redis 作为 broker 和 backend
app.conf.broker_url = 'redis://redis:6379/0'
app.conf.result_backend = 'redis://redis:6379/0'

app.conf.beat_schedule = {
    'update_ffk3': {
        'task': 'trend.tasks.update_ffk3',
        'schedule': crontab(minute='*'),
    }
}